/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-30 13:42:52
 * @LastEditTime : 2023-06-27 15:25:38
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\CameraGroup.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const CameraGroup = async ({ url, OptionsEvent, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'fullName@asc,tableName@asc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === 'babb06d2-7a34-422b-aa6b-00a487aedde9') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'code',
                title: '类型',
                valueType: 'select',
                valueEnum: { '-1': '所有', 0: '安全', 1: '重点区域', 2: '质量', 3: '科创中心' },
                rules: true,
                width: 100,
            },
            { ...commonTableList.tableName, rules: true, title: '区域名称' },
            { ...commonTableList.fullName, rules: true, title: '项目名称' },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '304cada6-0c4c-47a7-bf1e-c4b324a5df6f') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '95f4dd8a-a652-414a-9875-72a8a6701c8a') !== -1 && (
                            <OpenTwoRouter
                                key="TwoOne"
                                title="分组详情"
                                twoTitle="摄像头分组详情"
                                modal="TableList"
                                OptionsEvent={OptionsEvent}
                                other={{
                                    page: 'CameraGroupDetail',
                                    Permission,
                                    actionRef,
                                    oneData: record,
                                    header: data.columns,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === 'f0b06f3f-a0b4-4f17-b80c-07b2787e88d3') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
